class Login {
    private String userName;
    private String passWord;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public void loginfo(String userName, String passWord) throws UserNameException, PassWordException {
        if (!this.userName.equals(userName)) {
            throw new UserNameException("用户名错误异常.....");
        }
        if (!this.passWord.equals(passWord)) {
            throw new PassWordException("密码错误异常.....");
        }
        System.out.println("登陆成功!");
    }
}
public class Test {
    //实现一个简单的控制台版用户登陆程序, 程序启动提示用户输入用户名密码. 如果用户名密码出错, 使用自定义异常的方式来处理
    public static void main(String[] args) {
        Login login=new Login();
        login.setUserName("abcd");
        login.setPassWord("123");
        try{
            login.loginfo("abc","123");
        }catch(UserNameException e){
            e.printStackTrace();
        }catch (PassWordException e){
            e.printStackTrace();
        }finally {

        }
    }


}
